package com.acgist.polaris.compressor;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

import com.acgist.polaris.Compressor;
import com.acgist.polaris.entity.PayloadEntity;
import com.acgist.polaris.entity.StreamEntity;

/**
 * <p>数据流压缩机</p>
 * 
 * @author acgist
 */
public class StreamCompressor implements Compressor<InputStream, OutputStream> {

	private final StreamEntity streamEntity;
	
	public StreamCompressor() {
		this.streamEntity = StreamEntity.newStreamEntity();
	}

	@Override
	public void gc(InputStream input, OutputStream output) throws IOException {
		this.streamEntity.setSize(Long.valueOf(input.available()));
		output.write(this.streamEntity.buildDescription());
		final PayloadEntity payloadEntity = new PayloadEntity(input, output);
		payloadEntity.gc();
	}

	@Override
	public void ungc(InputStream input, OutputStream output) {
	}

	@Override
	public List<StreamEntity> list(InputStream input) {
		return null;
	}
	
}
